const mongoose = require('mongoose')
const Schema = mongoose.Schema
const moment = require('moment')

const TodoSchema = new Schema({
  name: {type: String},
  deadline: {type: Date},
  content: {type: String},
  status: {type: Number, default: 0},
})

TodoSchema.virtual("deadlineTime").get(function() {
  return moment(this.deadline).format("YYYY-MM-DD HH:mm:SS");
});

const Todo = mongoose.model('Todo', TodoSchema)

module.exports = Todo